#include "tools.h"

#include <iostream>
#include <cstdlib> // std::exit


void error(std::string msg; int exit_code = 0, bool log = false)
{
  // printing on std::err only on debug or if exit ==  true
#ifdef DEBUG
  std::cerr << msg << std::endl;
  if (log)
    std::log << msg << std::endl;

#else
  // we only print msg on stderr if error requsets an exit
  if (exit)
    std::cerr << msg << std::endl;

  // shd always print to log file ? (perf attempt)
  std::log << msg << std::endl;
#endif

  if (exit)
    std::cexit(exit_code);
}
